﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Master_Page/NovaMaster.master"
    AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Tecnicos_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link href="../Style/GridView.css" rel="stylesheet" type="text/css" />
    <link href="../Style/Tecnico.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="duascolunas">
        <fieldset class="consulta">
            <legend>
                <h1>
                    Técnicos</h1>
            </legend>
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Login"
                DataSourceID="SQLTecnicos" EnableModelValidation="True">
                <Columns>
                    <asp:BoundField DataField="Login" HeaderText="Login" ReadOnly="True"
                        SortExpression="Login" />
                    <asp:BoundField DataField="Nome" HeaderText="Nome" SortExpression="Nome" />
                    <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                    <asp:BoundField DataField="Ramal" HeaderText="Ramal" SortExpression="Ramal" />
                    <asp:TemplateField ShowHeader="False">
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                                CommandName="Delete" Text="Apagar"
                                OnClientClick="javascrit:return window.confirm(&quot;Você tem certeza que deseja deletar este técnico?&quot;)"></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <asp:SqlDataSource ID="SQLTecnicos" runat="server" ConnectionString="<%$ ConnectionStrings:chamados %>"
                DeleteCommand="DELETE FROM tecnicos WHERE (login = @Login)" ProviderName="<%$ ConnectionStrings:chamados.ProviderName %>"
                SelectCommand="SELECT login AS Login, nome AS Nome, email AS Email, ramal AS Ramal FROM tecnicos WHERE (login &lt;&gt; 'nenhum')"
                
                UpdateCommand="UPDATE tecnicos SET nome = @nome, email = @email, ramal = @ramal, login = @login WHERE (codigo = @Codigo)">
            </asp:SqlDataSource>
        </fieldset>
        <fieldset class="cadastro">
            <legend>
                <h1>
                    <asp:Literal ID="Nt" runat="server" Text="Novo Técnico"></asp:Literal></h1>
            </legend>
            <p>
                Nome:<br />
                <asp:TextBox ID="TBNome" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Campo obrigatório!"
                    CssClass="aviso" ControlToValidate="TBNome" Display="Dynamic" ValidationGroup="Cad"></asp:RequiredFieldValidator>
            </p>
            <p>
                Email:<br />
                <asp:TextBox ID="TBEmail" runat="server"></asp:TextBox></p>
            <p>
                Ramal:<br />
                <asp:TextBox ID="TBRamal" runat="server"></asp:TextBox></p>
            <p>
                Login:<br />
                <asp:TextBox ID="TBLogin" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Campo obrigatório!"
                    CssClass="aviso" ControlToValidate="TBLogin" Display="Dynamic" ValidationGroup="Cad"></asp:RequiredFieldValidator></p>
            <p>
                <asp:Label ID="Msg" runat="server" CssClass="aviso"></asp:Label></p>
            <p>
                <asp:Button ID="BTFinalizar" runat="server" Text="Cadastrar" ValidationGroup="Cad" OnClick="BTFinalizar_Click" />
                </p>
        </fieldset>
    </div>
</asp:Content>
